//package com.fingard.dsp.bank.directbank.citi01;
//
//import java.io.File;
//
//import com.fingard.dsp.bank.directbank.bankInterface.IForeignCurrency;
//import com.fingard.dsp.bank.directbank.fngrd01.util.StringHelper;
//import com.fingard.dsp.bank.reqrespobj.foreigncurrsingle.ReqForeignCurrSingle;
//import com.fingard.dsp.bank.reqrespobj.foreigncurrsingle.ReqQryForeignCurrSingle;
//import com.fingard.dsp.bank.reqrespobj.foreigncurrsingle.RetAtsForeignCurrSingle;
//import com.fingard.dsp.bank.reqrespobj.foreigncurrsingle.detail.RetAtsForeignCurrPayDetail;
//import com.fingard.xml.XmlTextReader;
//import com.fingard.xml.XmlTextWriter;
//
//import static com.fingard.io.FileHelper.*;
//
///**
//* 外币支付
//* */
//public class CITI01ForeignCurrSinglePay extends CITI01Base implements IForeignCurrency
//{
//    /**
//    * 支付
//    * */
//    @Override
//    public RetAtsForeignCurrSingle foreignCurrPay(ReqForeignCurrSingle reqForeignCurrSingle) throws Exception {
//        String hkcode = "HK";
//        if(hkcode.equals(reqForeignCurrSingle.singleDetail.payCounyeryCode)){
//            return foreignPayForHK(reqForeignCurrSingle);
//        } else {
//            return foreignPayForSG(reqForeignCurrSingle);
//        }
//    }
//
//
//    /**
//    * 花旗香港支付
//    * */
//    public RetAtsForeignCurrSingle foreignPayForHK(ReqForeignCurrSingle reqForeignCurrSingle) throws Exception{
//        RetAtsForeignCurrSingle retats = new RetAtsForeignCurrSingle(reqForeignCurrSingle.reqHeader);
//        RetAtsForeignCurrPayDetail tmpRetAtsDetail = new RetAtsForeignCurrPayDetail();
//        tmpRetAtsDetail.respCode = "";
//        if(tmpRetAtsDetail.respCode.length() == 0) {
//            XmlTextWriter xmlWriter = new XmlTextWriter();
//            writeCommonHeader(xmlWriter);
//            //支票支付190811
//            if(reqForeignCurrSingle.reqHeader.commandCode.equals("190811")){
//                writeFileContentCheque(xmlWriter,reqForeignCurrSingle);
//            }else{
//                if(reqForeignCurrSingle.singleDetail.payArea.equals("CN")){
//                    writeFileContentCN(xmlWriter,reqForeignCurrSingle);
//                }else {
//                    writeFileContentNew(xmlWriter, reqForeignCurrSingle);
//                }
//            }
//            if("api".equals(getBankConfig().getValueAsString("channelFlag")) || !reqForeignCurrSingle.reqHeader.commandCode.equals("190811")){
//                String[] tmpStrRet = sendToBank(xmlWriter.toXmlString(),"1908");//发送银行
//                if (tmpStrRet[0].length() == 0) {
//                    StringBuilder tmpSbMsg = new StringBuilder();
//                    //解析银行返回
//                    XmlTextReader tmpBkReader = loadBankRespXmlReader(tmpStrRet[1], tmpSbMsg);
//                    if (tmpBkReader != null) {
//                        String tmpRetCode = tmpBkReader.getFirstText("/Document/CstmrPmtStsRpt/OrgnlPmtInfAndSts/TxInfAndSts/TxSts");
//                        if (checkStatus(tmpRetCode) == 1) {
//                            tmpRetAtsDetail.respCode = "0";
//                            tmpRetAtsDetail.reqSeqID = reqForeignCurrSingle.singleDetail.askNumber;
//                            tmpRetAtsDetail.transState = "0000";
//                            tmpRetAtsDetail.payInfoCode = "0000";
//                            tmpRetAtsDetail.respInfo = "交易处理中";
//                        } else if(checkStatus(tmpRetCode) == 2){
//                            tmpRetAtsDetail.respCode = "-1";
//                            tmpRetAtsDetail.respInfo = "交易失败";
//                        } else if(checkStatus(tmpRetCode) == 3){
//                            tmpRetAtsDetail.respCode = "0";
//                            tmpRetAtsDetail.reqSeqID = reqForeignCurrSingle.singleDetail.askNumber;
//                            tmpRetAtsDetail.transState = "0000";
//                            tmpRetAtsDetail.payInfoCode = "0000";
//                            tmpRetAtsDetail.respInfo = "交易成功";
//                        } else{
//                            tmpRetAtsDetail.respCode = "-1";
//                            tmpRetAtsDetail.respInfo = "交易状态未知";
//                        }
//                    } else {
//                        tmpRetAtsDetail.respCode = "-1";
//                        tmpRetAtsDetail.respInfo = tmpSbMsg.toString();
//                    }
//                }else{
//                    tmpRetAtsDetail.respCode = "-1";
//                    tmpRetAtsDetail.respInfo = "交易失败";
//                }
//            }else {
//                String filefullname = getBankConfig().getValueAsString("localAddress") + reqForeignCurrSingle.singleDetail.payDate + "_" + reqForeignCurrSingle.singleDetail.askNumber;
//                WriteBankLogLn("接受到付款文件报文为：" + xmlWriter.toXmlString());
//                if (!exportContentToFile(xmlWriter.toXmlString(), filefullname)) {
//                    tmpRetAtsDetail.respCode = "0";
//                    tmpRetAtsDetail.respInfo = "生成付款文件失败";
//                    tmpRetAtsDetail.transState = "E1301";
//                    tmpRetAtsDetail.payInfoCode = "E1301";
//                    retats.writeRetDetail(tmpRetAtsDetail);
//                    return retats;
//                }
//                if (!encrpyFile(filefullname)) {
//                    tmpRetAtsDetail.respCode = "0";
//                    tmpRetAtsDetail.respInfo = "生成加密文件失败";
//                    tmpRetAtsDetail.transState = "E1301";
//                    tmpRetAtsDetail.payInfoCode = "E1301";
//                    retats.writeRetDetail(tmpRetAtsDetail);
//                    return retats;
//                }
//                File gpgFile = new File(filefullname + ".gpg");
//                String filename = getBankConfig().getValueAsString("fileNameType") + reqForeignCurrSingle.singleDetail.askNumber;
//                String content = readToString(gpgFile, "ascii");
//                WriteBankLogLn("生成的加密付款文件内容为：" + content);
//                if (!uploadFile(filename, content)) {
//                    tmpRetAtsDetail.respCode = "0";
//                    tmpRetAtsDetail.respInfo = "上送文件至SFTP服务器失败";
//                    tmpRetAtsDetail.transState = "E1301";
//                    tmpRetAtsDetail.payInfoCode = "E1301";
//                    retats.writeRetDetail(tmpRetAtsDetail);
//                    return retats;
//                }
//
//                tmpRetAtsDetail.respCode = "0";
//                tmpRetAtsDetail.respInfo = "发送文件成功";
//                tmpRetAtsDetail.transState = "0000";
//                tmpRetAtsDetail.payInfoCode = "0000";
//            }
//            retats.writeRetDetail(tmpRetAtsDetail);
//
//        }
//        return retats;
//    }
//
//    /**
//    * 花旗新加坡支付
//    * */
//    public RetAtsForeignCurrSingle foreignPayForSG(ReqForeignCurrSingle reqForeignCurrSingle) throws Exception{
//        RetAtsForeignCurrSingle retats = new RetAtsForeignCurrSingle(reqForeignCurrSingle.reqHeader);
//        RetAtsForeignCurrPayDetail tmpRetAtsDetail = new RetAtsForeignCurrPayDetail();
//        tmpRetAtsDetail.respCode = "";
//        if(tmpRetAtsDetail.respCode.length() == 0)
//        {
//            XmlTextWriter xmlWriter = new XmlTextWriter();
//            writeCommonHeader(xmlWriter);
//            if(reqForeignCurrSingle.reqHeader.commandCode.equals("190811")){
//                writeFileContentChequeSG(xmlWriter,reqForeignCurrSingle);
//            }else{
//                writeFileContentForSG(xmlWriter,reqForeignCurrSingle);
//            }
//            if("api".equals(getBankConfig().getValueAsString("channelFlag"))){
//                String[] tmpStrRet = sendToBank(xmlWriter.toXmlString(),"1908");//发送银行
//                if (tmpStrRet[0].length() == 0) {
//                    StringBuilder tmpSbMsg = new StringBuilder();
//                    //解析银行返回
//                    XmlTextReader tmpBkReader = loadBankRespXmlReader(tmpStrRet[1], tmpSbMsg);
//                    if (tmpBkReader != null) {
//                        String tmpRetCode = tmpBkReader.getFirstText("/Document/CstmrPmtStsRpt/OrgnlPmtInfAndSts/TxInfAndSts/TxSts");
//                        if (checkStatus(tmpRetCode) == 1) {
//                            tmpRetAtsDetail.respCode = "0";
//                            tmpRetAtsDetail.reqSeqID = reqForeignCurrSingle.singleDetail.askNumber;
//                            tmpRetAtsDetail.transState = "0000";
//                            tmpRetAtsDetail.payInfoCode = "0000";
//                            tmpRetAtsDetail.respInfo = "交易处理中";
//                        } else if(checkStatus(tmpRetCode) == 2){
//                            tmpRetAtsDetail.respCode = "-1";
//                            tmpRetAtsDetail.respInfo = "交易失败";
//                        } else if(checkStatus(tmpRetCode) == 3){
//                            tmpRetAtsDetail.respCode = "0";
//                            tmpRetAtsDetail.reqSeqID = reqForeignCurrSingle.singleDetail.askNumber;
//                            tmpRetAtsDetail.transState = "0000";
//                            tmpRetAtsDetail.payInfoCode = "0000";
//                            tmpRetAtsDetail.respInfo = "交易成功";
//                        } else{
//                            tmpRetAtsDetail.respCode = "-1";
//                            tmpRetAtsDetail.respInfo = "交易状态未知";
//                        }
//                    } else {
//                        tmpRetAtsDetail.respCode = "-1";
//                        tmpRetAtsDetail.respInfo = tmpSbMsg.toString();
//                    }
//                }else{
//                    tmpRetAtsDetail.respCode = "-1";
//                    tmpRetAtsDetail.respInfo = "交易失败";
//                }
//            }else {
//                String filefullname = getBankConfig().getValueAsString("localAddress") + reqForeignCurrSingle.singleDetail.payDate + "_" + reqForeignCurrSingle.singleDetail.askNumber;
//                if (!exportContentToFile(xmlWriter.toXmlString(), filefullname)) {
//                    tmpRetAtsDetail.respCode = "0";
//                    tmpRetAtsDetail.respInfo = "生成付款文件失败";
//                    tmpRetAtsDetail.transState = "E1301";
//                    tmpRetAtsDetail.payInfoCode = "E1301";
//                    retats.writeRetDetail(tmpRetAtsDetail);
//                    return retats;
//                }
//                if (!encrpyFile(filefullname)) {
//                    tmpRetAtsDetail.respCode = "0";
//                    tmpRetAtsDetail.respInfo = "生成加密文件失败";
//                    tmpRetAtsDetail.transState = "E1301";
//                    tmpRetAtsDetail.payInfoCode = "E1301";
//                    retats.writeRetDetail(tmpRetAtsDetail);
//                    return retats;
//                }
//                File gpgFile = new File(filefullname + ".gpg");
//                String filename = getBankConfig().getValueAsString("fileNameType") + reqForeignCurrSingle.singleDetail.askNumber;
//                String content = readToString(gpgFile, "ascii");
//                if (!uploadFile(filename, content)) {
//                    tmpRetAtsDetail.respCode = "0";
//                    tmpRetAtsDetail.respInfo = "上送文件至SFTP服务器失败";
//                    tmpRetAtsDetail.transState = "E1301";
//                    tmpRetAtsDetail.payInfoCode = "E1301";
//                    retats.writeRetDetail(tmpRetAtsDetail);
//                    return retats;
//                }
//
//                tmpRetAtsDetail.respCode = "0";
//                tmpRetAtsDetail.respInfo = "发送文件成功";
//                tmpRetAtsDetail.transState = "0000";
//                tmpRetAtsDetail.payInfoCode = "0000";
//            }
//            retats.writeRetDetail(tmpRetAtsDetail);
//
//        }
//        return retats;
//    }
//
//    /**
//     * 查询
//     * */
//    @Override
//    public RetAtsForeignCurrSingle qryForeignCurrPay(ReqQryForeignCurrSingle reqQryForeignCurrSingle) throws Exception {
//        RetAtsForeignCurrSingle retats = new RetAtsForeignCurrSingle(reqQryForeignCurrSingle.reqHeader);
//        RetAtsForeignCurrPayDetail detail = new RetAtsForeignCurrPayDetail();
//        detail.reqSeqID =  reqQryForeignCurrSingle.askNumber;
////        String filePath = getBankConfig().getValueAsString("DealedPath");
////        String requestDay = reqQryForeignCurrSingle.bgnDate;
////        String date = requestDay.substring(0,4) + requestDay.substring(5,7) + requestDay.substring(8,10);
////        String seqID = reqQryForeignCurrSingle.reqHeader.reqSeqID;
////        String ackFileFullName =  filePath + File.separator + date + File.separator + seqID + "_ACK";
////        if(existFile(ackFileFullName))
//        if(getBankConfig().getValueAsString("channelFlag")!=null){
//            XmlTextWriter xmlWriter = new XmlTextWriter();
//            xmlWriter.writeStartDocByDeclaration("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
//            xmlWriter.writeElementAttribute("paymentInquiryRequest", "xmlns", "http://com.citi.citiconnect/services/types/inquiries/payment/v1");
//           // xmlWriter.writeElementString("GlobalTranNo","278582453");
//            xmlWriter.writeElementString("EndToEndId",detail.reqSeqID);
//            //xmlWriter.writeElementString("directDebitInd","Y");
//            xmlWriter.writeEndDocument();
//            String[] tmpRetBkStr = sendToBankForStatus(xmlWriter.toXmlString(),detail.reqSeqID);
//            if (tmpRetBkStr[0].length() == 0) {
//                StringBuilder tmpSbMsg = new StringBuilder();
//                XmlTextReader tmpBkReader = loadBankRespXmlReader(tmpRetBkStr[1], tmpSbMsg);
//                if (tmpBkReader != null) {
//                    String tmpRetCode = tmpBkReader.getFirstText("/Document/CstmrPmtStsRpt/OrgnlGrpInfAndSts/OrgnlMsgId");
//                    if (!com.fingard.text.StringHelper.isNullOrEmpty(tmpRetCode)) {
//
//                        String repCode = tmpBkReader.getFirstText("/Document/CstmrPmtStsRpt/OrgnlPmtInfAndSts/TxInfAndSts/TxSts");
//                        detail.respCode = "0";
//                        detail.respInfo = tmpBkReader.getFirstText("/Message/Body/ErrMsg");
//                        if(checkStatus(repCode) == 1){
//                            detail.respInfo = "交易处理中";
//                        }
//                        if(checkStatus(repCode) == 2){
//                            detail.respInfo = "交易失败:" + tmpBkReader.getFirstText("/Document/CstmrPmtStsRpt/OrgnlPmtInfAndSts/TxInfAndSts/StsRsnInf/AddtlInf");
//                        }
//                        if(checkStatus(repCode) == 3){
//                            detail.respInfo = "交易成功";
//                        }
//                        if(checkStatus(repCode) == 0){
//                            detail.respInfo = "未知状态";
//                        }
//                        detail.transState = "190801" + checkStatus(repCode);
//                        detail.payInfoCode = detail.transState;
//                    } else {
//                        detail.respCode = "-1";
//                        detail.respInfo = "请求失败";
//                    }
//                } else {
//                    detail.respCode = "-1";
//                    detail.respInfo = tmpSbMsg.toString();
//                }
//            } else {
//                detail.respCode = "-1";
//                detail.respInfo = tmpRetBkStr[1];
//            }
//        }else {
//            //解密文件
//            //decryptFile("ACK.txt");
//            String[] result = judgeMTStatu2(reqQryForeignCurrSingle.askNumber, reqQryForeignCurrSingle.getBgnDateTime());
//            //判断对账单是否有对应的流水号
//            if ("0".equals(result[0])) {
//                detail.transState = "VALID";
//                detail.payInfoCode = "VALID";
//                detail.respCode = "0";
//                detail.respInfo = "SUCCESS";
//                String repCode = result[1];
//                if(repCode!=null){
//                    if(checkStatus(repCode) == 1){
//                        detail.respInfo = "交易处理中";
//                    }
//                    if(checkStatus(repCode) == 2){
//                        detail.respInfo = "交易失败";
//                    }
//                    if(checkStatus(repCode) == 3){
//                        detail.respInfo = "交易成功";
//                    }
//                    if(checkStatus(repCode) == 0){
//                        detail.respInfo = "未知状态";
//                    }
//                    detail.transState = "190801" + checkStatus(repCode);
//                    detail.payInfoCode = detail.transState;
//                }
//            } else if ("2".equals(result[0])) {
//                detail.transState = "FAIL";
//                detail.payInfoCode = "FAIL";
//                detail.respCode = "0";
//                detail.respInfo = result[1];
//            } else {
//                detail.payInfoCode = "UNKNOWN";
//                detail.transState = "UNKNOWN";
//                detail.respCode = "0";
//                detail.respInfo = StringHelper.isNullOrEmpty(result[1]) ? "银行未返回对账文件，请稍后查询" : result[1];
//            }
////        else
////        {
////            String sftpFiles  = downloadFile();
////            String localAddress = trimEndFileSp(getBankConfig().getValueAsString("ReceiveFilePath"));
////            String[] filenames = sftpFiles.split("\\|");
////            for(String name : filenames)
////            {
////                if(StringHelper.isNullOrEmpty(name)){
////                    continue;
////                }
////                String fullPath  = localAddress + File.separator + name;
////                decrpyFile(fullPath);
////            }
////            for(String name : filenames)
////            {
////                handleNewFile(name);
////            }
////            if(existFile(ackFileFullName)){
////                //判断对账单是否有对应的流水号
////                if(judgeMTStatu(reqQryForeignCurrSingle.reqHeader.reqSeqID)) {
////                    detail.transState = "Valid";
////                    detail.payInfoCode = "SUCCESS";
////                    detail.respCode = "0";
////                }
////                else{
////                    detail.payInfoCode = "UNKOWN";
////                    detail.transState = "UNKOWN";
////                    detail.respCode = "0";
////                    detail.respInfo = "银行未返回对账文件，请稍后查询";
////                }
////            }
////            else {
////                detail.payInfoCode = "UNKOWN";
////                detail.transState = "UNKOWN";
////                detail.respCode = "0";
////                detail.respInfo = "银行未返回，请稍后查询";
////            }
////        }
//        }
//        retats.writeRetDetail(detail);
//        return retats;
//    }
//
//    private void writeFileContent(XmlTextWriter xmlWriter, ReqForeignCurrSingle reqForeignCurrSingle) throws Exception {
//        String currency = convertCurToBank(reqForeignCurrSingle.singleDetail.payCur);
//
//        xmlWriter.writeStartElement("GrpHdr");
//        xmlWriter.writeElementStringNotNull("MsgId", reqForeignCurrSingle.singleDetail.askNumber);
//
//        String date = reqForeignCurrSingle.singleDetail.payDate + "T" + reqForeignCurrSingle.singleDetail.payTime;
//        xmlWriter.writeElementStringNotNull("CreDtTm", date);
//        xmlWriter.writeElementStringNotNull("NbOfTxs", "1");
//        xmlWriter.writeStartElement("InitgPty");
//        xmlWriter.writeElementStringNotNull("Nm", reqForeignCurrSingle.singleDetail.payName);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("PmtInf");
//        //流水号
//        xmlWriter.writeElementStringNotNull("PmtInfId", reqForeignCurrSingle.singleDetail.askNumber);
//        xmlWriter.writeElementStringNotNull("PmtMtd", "TRF");
//        xmlWriter.writeStartElement("PmtTpInf");
//        xmlWriter.writeStartElement("SvcLvl");
//        String isFast = reqForeignCurrSingle.singleDetail.paySpd;
//        String recCrtyCode = reqForeignCurrSingle.singleDetail.recCtryCode;
//        //香港本地付款 港币和人民币走加急
//        if(recCrtyCode!=null && recCrtyCode.equals("HK")){
//            if (currency != null &&(currency.equals("HKD") || currency.equals("CNY"))) {
//                isFast = "1";
//            }
//        }
//        if(isFast!=null && isFast.equals("1")){
//            xmlWriter.writeElementStringNotNull("Cd", "NURG");
//        }else {
//            xmlWriter.writeElementStringNotNull("Cd", "URGP");
//        }
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeElementStringNotNull("ReqdExctnDt", reqForeignCurrSingle.singleDetail.payDate);
//        xmlWriter.writeStartElement("Dbtr");
//        xmlWriter.writeElementStringNotNull("Nm", reqForeignCurrSingle.singleDetail.payName);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("DbtrAcct");
//        xmlWriter.writeStartElement("Id");
//        xmlWriter.writeStartElement("Othr");
//        xmlWriter.writeElementStringNotNull("Id", reqForeignCurrSingle.singleDetail.payAct);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("DbtrAgt");
//        xmlWriter.writeStartElement("FinInstnId");
//        xmlWriter.writeElementStringNotNull("BIC", reqForeignCurrSingle.singleDetail.paySWIFTCODE);
//        if(isFast!=null && isFast.equals("0")) {
//            xmlWriter.writeStartElement("PstlAdr");
//            xmlWriter.writeElementStringNotNull("Ctry", reqForeignCurrSingle.singleDetail.recCtryCode);
//            xmlWriter.writeEndElement();
//        }
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("CdtTrfTxInf");
//        xmlWriter.writeStartElement("PmtId");
//        xmlWriter.writeElementStringNotNull("EndToEndId", reqForeignCurrSingle.singleDetail.askNumber);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("Amt");
//        xmlWriter.writeElementAttribute("InstdAmt",reqForeignCurrSingle.singleDetail.payAmount,"Ccy",currency);
//        xmlWriter.writeEndElement();
//        if(isFast!=null && isFast.equals("0")) {
//            xmlWriter.writeElementStringNotNull("ChrgBr", FeeBearer(reqForeignCurrSingle.singleDetail.costMode));
//        }
//        xmlWriter.writeStartElement("CdtrAgt");
//        xmlWriter.writeStartElement("FinInstnId");
//        if(isFast!=null && isFast.equals("1")){
//            xmlWriter.writeStartElement("ClrSysMmbId");
//            xmlWriter.writeElementStringNotNull("MmbId", reqForeignCurrSingle.singleDetail.recCNAPSCode);
//            xmlWriter.writeEndElement();
//        }else {
//
//            xmlWriter.writeElementStringNotNull("BIC", reqForeignCurrSingle.singleDetail.recSWIFTCODE);
//            xmlWriter.writeElementStringNotNull("Nm", reqForeignCurrSingle.singleDetail.recBankName);
//            xmlWriter.writeStartElement("PstlAdr");
//            xmlWriter.writeElementStringNotNull("AdrTp", "ADDR");
//            xmlWriter.writeElementStringNotNull("AdrLine", "TEST");
//            xmlWriter.writeEndElement();
//        }
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("Cdtr");
//        xmlWriter.writeElementStringNotNull("Nm", reqForeignCurrSingle.singleDetail.recName);
//        if(isFast!=null && isFast.equals("0")) {
//            xmlWriter.writeStartElement("PstlAdr");
//            xmlWriter.writeElementStringNotNull("AdrTp", "ADDR");
//            xmlWriter.writeElementStringNotNull("AdrLine", reqForeignCurrSingle.singleDetail.recBankAddress);
//            xmlWriter.writeEndElement();
//        }
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("CdtrAcct");
//        xmlWriter.writeStartElement("Id");
//        xmlWriter.writeStartElement("Othr");
//        xmlWriter.writeElementStringNotNull("Id", reqForeignCurrSingle.singleDetail.recAct);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        if(isFast!=null && isFast.equals("1")) {
//            xmlWriter.writeStartElement("Purp");
//            xmlWriter.writeElementStringNotNull("Prtry", "23");
//
//            xmlWriter.writeEndElement();
//        }
//        xmlWriter.writeStartElement("RmtInf");
//        if(isFast!=null && isFast.equals("1")){
//            xmlWriter.writeElementStringNotNull("Ustrd", "/IDTP/BBAN");
//        }else {
//            xmlWriter.writeElementStringNotNull("Ustrd", reqForeignCurrSingle.singleDetail.memo);
//        }
//        xmlWriter.writeEndDocument();
//        xmlWriter.writeStartDocByDeclaration("\r\n"+"</Document>");
//    }
//
//    private void writeFileContentNew(XmlTextWriter xmlWriter, ReqForeignCurrSingle reqForeignCurrSingle) throws Exception {
//        String currency = convertCurToBank(reqForeignCurrSingle.singleDetail.payCur);
//
//        xmlWriter.writeStartElement("GrpHdr");
//        xmlWriter.writeElementStringNotNull("MsgId", reqForeignCurrSingle.singleDetail.askNumber);
//
//        String date = reqForeignCurrSingle.singleDetail.payDate + "T" + reqForeignCurrSingle.singleDetail.payTime;
//        xmlWriter.writeElementStringNotNull("CreDtTm", date);
//        xmlWriter.writeElementStringNotNull("NbOfTxs", "1");
//        xmlWriter.writeStartElement("InitgPty");
//        String nm = reqForeignCurrSingle.singleDetail.payName;
//        if (currency != null &&(currency.equals("HKD"))) {
//            //取映射账户名
//             nm = getBankConfig().getMapValueByKey("actNameMapping",reqForeignCurrSingle.singleDetail.payAct);
//            if(nm.length()==0){
//                nm = reqForeignCurrSingle.singleDetail.payName;
//            }
//        }
//        xmlWriter.writeElementStringNotNull("Nm",nm);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("PmtInf");
//        //流水号
//        xmlWriter.writeElementStringNotNull("PmtInfId", reqForeignCurrSingle.singleDetail.askNumber);
//        xmlWriter.writeElementStringNotNull("PmtMtd", "TRF");
//        xmlWriter.writeStartElement("PmtTpInf");
//        xmlWriter.writeStartElement("SvcLvl");
//        String isFast = reqForeignCurrSingle.singleDetail.paySpd;
//        String recCrtyCode = reqForeignCurrSingle.singleDetail.recCtryCode;
//        //香港先区分地区再币种区分code
//        if (currency != null &&(currency.equals("HKD")) && reqForeignCurrSingle.singleDetail.recCtryCode.equals("HK")) {
//            xmlWriter.writeElementStringNotNull("Cd", "NURG");
//        }else{
//            xmlWriter.writeElementStringNotNull("Cd", "URGP");
//        }
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeElementStringNotNull("ReqdExctnDt", reqForeignCurrSingle.singleDetail.payDate);
//        xmlWriter.writeStartElement("Dbtr");
//        xmlWriter.writeElementStringNotNull("Nm", nm);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("DbtrAcct");
//        xmlWriter.writeStartElement("Id");
//        xmlWriter.writeStartElement("Othr");
//        xmlWriter.writeElementStringNotNull("Id", reqForeignCurrSingle.singleDetail.payAct);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("DbtrAgt");
//        xmlWriter.writeStartElement("FinInstnId");
//        xmlWriter.writeElementStringNotNull("BIC", reqForeignCurrSingle.singleDetail.paySWIFTCODE);
//        if(isFast!=null && isFast.equals("0")) {
//            xmlWriter.writeStartElement("PstlAdr");
//            xmlWriter.writeElementStringNotNull("Ctry", reqForeignCurrSingle.singleDetail.payCountryCode);
//            xmlWriter.writeEndElement();
//        }
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("CdtTrfTxInf");
//        xmlWriter.writeStartElement("PmtId");
//        xmlWriter.writeElementStringNotNull("EndToEndId", reqForeignCurrSingle.singleDetail.askNumber);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("Amt");
//        xmlWriter.writeElementAttribute("InstdAmt",reqForeignCurrSingle.singleDetail.payAmount,"Ccy",currency);
//        xmlWriter.writeEndElement();
//        if(isFast!=null && isFast.equals("0")) {
//            xmlWriter.writeElementStringNotNull("ChrgBr", FeeBearer(reqForeignCurrSingle.singleDetail.costMode));
//        }
//        xmlWriter.writeStartElement("CdtrAgt");
//        xmlWriter.writeStartElement("FinInstnId");
//
//            if(currency != null &&currency.equals("HKD") && reqForeignCurrSingle.singleDetail.recCtryCode.equals("HK")){
//                xmlWriter.writeStartElement("ClrSysMmbId");
//                xmlWriter.writeElementStringNotNull("MmbId", reqForeignCurrSingle.singleDetail.recCNAPSCode);
//                xmlWriter.writeEndElement();
//                xmlWriter.writeStartElement("PstlAdr");
//                xmlWriter.writeElementStringNotNull("Ctry", reqForeignCurrSingle.singleDetail.recCtryCode);
//                xmlWriter.writeEndElement();
//            }else {
//                xmlWriter.writeElementStringNotNull("BIC", reqForeignCurrSingle.singleDetail.recSWIFTCODE);
//                xmlWriter.writeElementStringNotNull("Nm", reqForeignCurrSingle.singleDetail.recBankName);
//                xmlWriter.writeStartElement("PstlAdr");
//                xmlWriter.writeElementStringNotNull("AdrTp", "ADDR");
//                xmlWriter.writeElementStringNotNull("Ctry", reqForeignCurrSingle.singleDetail.recCtryCode);
//                xmlWriter.writeElementStringNotNull("AdrLine", "TEST");
//                xmlWriter.writeEndElement();
//            }
//
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("Cdtr");
//        xmlWriter.writeElementStringNotNull("Nm", reqForeignCurrSingle.singleDetail.recName);
//        if(isFast!=null && isFast.equals("0")) {
//            xmlWriter.writeStartElement("PstlAdr");
//            xmlWriter.writeElementStringNotNull("AdrTp", "ADDR");
//            xmlWriter.writeElementStringNotNull("Ctry", reqForeignCurrSingle.singleDetail.recCtryCode);
//            xmlWriter.writeElementStringNotNull("AdrLine", "TEST");
//            xmlWriter.writeEndElement();
//        }
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("CdtrAcct");
//        xmlWriter.writeStartElement("Id");
//        xmlWriter.writeStartElement("Othr");
//        xmlWriter.writeElementStringNotNull("Id", reqForeignCurrSingle.singleDetail.recAct);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        if(isFast!=null && isFast.equals("1")) {
//            xmlWriter.writeStartElement("Purp");
//            xmlWriter.writeElementStringNotNull("Prtry", "23");
//
//            xmlWriter.writeEndElement();
//        }
//        xmlWriter.writeStartElement("RmtInf");
//        if(isFast!=null && isFast.equals("1")){
//            xmlWriter.writeElementStringNotNull("Ustrd", "/IDTP/BBAN");
//        }else {
//            xmlWriter.writeElementStringNotNull("Ustrd", reqForeignCurrSingle.singleDetail.memo);
//        }
//        xmlWriter.writeEndDocument();
//        xmlWriter.writeStartDocByDeclaration("\r\n"+"</Document>");
//    }
//
//    private void writeFileContentCN(XmlTextWriter xmlWriter, ReqForeignCurrSingle reqForeignCurrSingle) throws Exception {
//        xmlWriter.writeStartElement("GrpHdr");
//        xmlWriter.writeElementStringNotNull("MsgId", reqForeignCurrSingle.singleDetail.askNumber);
//        String currency = convertCurToBank(reqForeignCurrSingle.singleDetail.payCur);
//        String date = reqForeignCurrSingle.singleDetail.payDate + "T" + reqForeignCurrSingle.singleDetail.payTime;
//        xmlWriter.writeElementStringNotNull("CreDtTm", date);
//        xmlWriter.writeElementStringNotNull("NbOfTxs", "1");
//        xmlWriter.writeStartElement("InitgPty");
//        xmlWriter.writeElementStringNotNull("Nm", reqForeignCurrSingle.singleDetail.payName);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("PmtInf");
//        //流水号
//        xmlWriter.writeElementStringNotNull("PmtInfId", reqForeignCurrSingle.singleDetail.askNumber);
//        xmlWriter.writeElementStringNotNull("PmtMtd", "TRF");
//        xmlWriter.writeStartElement("PmtTpInf");
//        xmlWriter.writeStartElement("SvcLvl");
//        xmlWriter.writeElementStringNotNull("Cd", "URGP");
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeElementStringNotNull("ReqdExctnDt", reqForeignCurrSingle.singleDetail.payDate);
//        xmlWriter.writeStartElement("Dbtr");
//        xmlWriter.writeElementStringNotNull("Nm", reqForeignCurrSingle.singleDetail.payName);
//        xmlWriter.writeStartElement("PstlAdr");
//        xmlWriter.writeElementStringNotNull("AdrLine", "TEST ORDERING PARTY ADDRESS 1");
//        xmlWriter.writeEndElement();
//
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("DbtrAcct");
//        xmlWriter.writeStartElement("Id");
//        xmlWriter.writeStartElement("Othr");
//        xmlWriter.writeElementStringNotNull("Id", reqForeignCurrSingle.singleDetail.payAct);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeElementStringNotNull("Ccy", currency);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("DbtrAgt");
//        xmlWriter.writeStartElement("FinInstnId");
//        xmlWriter.writeElementStringNotNull("BIC", reqForeignCurrSingle.singleDetail.paySWIFTCODE);
//        xmlWriter.writeStartElement("PstlAdr");
//        xmlWriter.writeElementStringNotNull("Ctry", reqForeignCurrSingle.singleDetail.payArea);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("CdtTrfTxInf");
//        xmlWriter.writeStartElement("PmtId");
//        xmlWriter.writeElementStringNotNull("InstrId", reqForeignCurrSingle.singleDetail.askNumber + "1");
//
//        xmlWriter.writeElementStringNotNull("EndToEndId", reqForeignCurrSingle.singleDetail.askNumber);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("Amt");
//        xmlWriter.writeElementAttribute("InstdAmt",reqForeignCurrSingle.singleDetail.payAmount,"Ccy",currency);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeElementStringNotNull("ChrgBr", FeeBearer(reqForeignCurrSingle.singleDetail.costMode));
//        xmlWriter.writeStartElement("CdtrAgt");
//        xmlWriter.writeStartElement("FinInstnId");
//        xmlWriter.writeStartElement("ClrSysMmbId");
//        xmlWriter.writeElementStringNotNull("MmbId", reqForeignCurrSingle.singleDetail.recCNAPSCode);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeElementStringNotNull("Nm",reqForeignCurrSingle.singleDetail.recBnkName);
//        xmlWriter.writeStartElement("PstlAdr");
//        xmlWriter.writeElementStringNotNull("Ctry", reqForeignCurrSingle.singleDetail.payArea);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("Cdtr");
//        xmlWriter.writeElementStringNotNull("Nm", reqForeignCurrSingle.singleDetail.recName);
//        xmlWriter.writeStartElement("PstlAdr");
//        xmlWriter.writeElementStringNotNull("AdrLine", "TEST");
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("CdtrAcct");
//        xmlWriter.writeStartElement("Id");
//        xmlWriter.writeStartElement("Othr");
//        xmlWriter.writeElementStringNotNull("Id", reqForeignCurrSingle.singleDetail.recAct);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("RmtInf");
//        String isFast = reqForeignCurrSingle.singleDetail.paySpd;
//        if(isFast!=null && isFast.equals("1")){
//            xmlWriter.writeElementStringNotNull("Ustrd", "/IDTP/BBAN");
//        }else {
//            xmlWriter.writeElementStringNotNull("Ustrd", reqForeignCurrSingle.singleDetail.memo);
//        }
//        xmlWriter.writeEndDocument();
//        xmlWriter.writeStartDocByDeclaration("\r\n"+"</Document>");
//    }
//
//    private void writeFileContentCheque(XmlTextWriter xmlWriter, ReqForeignCurrSingle reqForeignCurrSingle) throws Exception {
//        xmlWriter.writeStartElement("GrpHdr");
//        xmlWriter.writeElementStringNotNull("MsgId", reqForeignCurrSingle.singleDetail.askNumber);
//
//        String date = reqForeignCurrSingle.singleDetail.payDate + "T" + reqForeignCurrSingle.singleDetail.payTime;
//        xmlWriter.writeElementStringNotNull("CreDtTm", date);
//        xmlWriter.writeElementStringNotNull("NbOfTxs", "1");
//        xmlWriter.writeElementStringNotNull("CtrlSum", reqForeignCurrSingle.singleDetail.payAmount);
//        xmlWriter.writeStartElement("InitgPty");
//        xmlWriter.writeElementStringNotNull("Nm", reqForeignCurrSingle.singleDetail.payName);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("PmtInf");
//        //流水号
//        xmlWriter.writeElementStringNotNull("PmtInfId", reqForeignCurrSingle.singleDetail.askNumber);
//        xmlWriter.writeElementStringNotNull("PmtMtd", "CHK");
//        xmlWriter.writeElementStringNotNull("NbOfTxs", "1");
//        xmlWriter.writeElementStringNotNull("CtrlSum", reqForeignCurrSingle.singleDetail.payAmount);
//
//        xmlWriter.writeStartElement("PmtTpInf");
//        xmlWriter.writeStartElement("SvcLvl");
//        xmlWriter.writeElementStringNotNull("Cd", "NURG");
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeElementStringNotNull("ReqdExctnDt", reqForeignCurrSingle.singleDetail.payDate);
//        xmlWriter.writeStartElement("Dbtr");
//        xmlWriter.writeElementStringNotNull("Nm", reqForeignCurrSingle.singleDetail.payName);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("DbtrAcct");
//        xmlWriter.writeStartElement("Id");
//        xmlWriter.writeStartElement("Othr");
//        xmlWriter.writeElementStringNotNull("Id", reqForeignCurrSingle.singleDetail.payAct);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        String currency = convertCurToBank(reqForeignCurrSingle.singleDetail.payCur);
//
//        xmlWriter.writeElementStringNotNull("Ccy", currency);
//
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("DbtrAgt");
//        xmlWriter.writeStartElement("FinInstnId");
//        xmlWriter.writeElementStringNotNull("BIC", reqForeignCurrSingle.singleDetail.paySWIFTCODE);
//        xmlWriter.writeStartElement("PstlAdr");
//        xmlWriter.writeElementStringNotNull("Ctry", reqForeignCurrSingle.singleDetail.payArea);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("CdtTrfTxInf");
//        xmlWriter.writeStartElement("PmtId");
//        xmlWriter.writeElementStringNotNull("InstrId","01HK10004100052019");
//        xmlWriter.writeElementStringNotNull("EndToEndId", reqForeignCurrSingle.singleDetail.askNumber);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("Amt");
//        xmlWriter.writeElementAttribute("InstdAmt",reqForeignCurrSingle.singleDetail.payAmount,"Ccy",currency);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("ChqInstr");
//        xmlWriter.writeStartElement("DlvryMtd");
//        xmlWriter.writeElementStringNotNull("Cd",reqForeignCurrSingle.singleDetail.recCheque.equals("1")?"MLCD":"MLDB");
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("DlvrTo");
//        xmlWriter.writeElementStringNotNull("Nm", reqForeignCurrSingle.singleDetail.recName);
//        xmlWriter.writeStartElement("Adr");
//        xmlWriter.writeElementStringNotNull("AdrLine", reqForeignCurrSingle.singleDetail.chequeAddr); //支票邮寄地址 reqForeignCurrSingle.singleDetail.chequeAddr
//        xmlWriter.writeElementStringNotNull("AdrLine", "TEST");
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("Cdtr");
//        xmlWriter.writeElementStringNotNull("Nm", reqForeignCurrSingle.singleDetail.recName);
//        xmlWriter.writeStartElement("PstlAdr");
//        xmlWriter.writeElementStringNotNull("Ctry", "HK");
//        xmlWriter.writeElementStringNotNull("AdrLine", "123 Building, Level 45");
//        xmlWriter.writeElementStringNotNull("AdrLine", "Abc Street, New Town 67-8, 90123");
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//
//
//        xmlWriter.writeEndDocument();
//        xmlWriter.writeStartDocByDeclaration("\r\n"+"</Document>");
//    }
//
//    private void writeFileContentChequeSG(XmlTextWriter xmlWriter, ReqForeignCurrSingle reqForeignCurrSingle) throws Exception {
//        xmlWriter.writeStartElement("GrpHdr");
//        xmlWriter.writeElementStringNotNull("MsgId", reqForeignCurrSingle.singleDetail.askNumber);
//
//        String date = reqForeignCurrSingle.singleDetail.payDate + "T" + reqForeignCurrSingle.singleDetail.payTime;
//        xmlWriter.writeElementStringNotNull("CreDtTm", date);
//        xmlWriter.writeElementStringNotNull("NbOfTxs", "1");
//        xmlWriter.writeStartElement("InitgPty");
//        xmlWriter.writeElementStringNotNull("Nm", reqForeignCurrSingle.singleDetail.payName);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("PmtInf");
//        //流水号
//        xmlWriter.writeElementStringNotNull("PmtInfId", reqForeignCurrSingle.singleDetail.askNumber);
//        xmlWriter.writeElementStringNotNull("PmtMtd", "CHK");
//
//        xmlWriter.writeElementStringNotNull("ReqdExctnDt", reqForeignCurrSingle.singleDetail.payDate);
//        xmlWriter.writeStartElement("Dbtr");
//        xmlWriter.writeElementStringNotNull("Nm", reqForeignCurrSingle.singleDetail.payName);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("DbtrAcct");
//        xmlWriter.writeStartElement("Id");
//        xmlWriter.writeStartElement("Othr");
//        xmlWriter.writeElementStringNotNull("Id", reqForeignCurrSingle.singleDetail.payAct);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("DbtrAgt");
//        xmlWriter.writeStartElement("FinInstnId");
//        xmlWriter.writeElementStringNotNull("BIC", reqForeignCurrSingle.singleDetail.paySWIFTCODE);
//        xmlWriter.writeStartElement("PstlAdr");
//        xmlWriter.writeElementStringNotNull("Ctry", "SG");
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("CdtTrfTxInf");
//        xmlWriter.writeStartElement("PmtId");
//        xmlWriter.writeElementStringNotNull("EndToEndId", reqForeignCurrSingle.singleDetail.askNumber);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("Amt");
//        String currency = convertCurToBank(reqForeignCurrSingle.singleDetail.payCur);
//        xmlWriter.writeElementAttribute("InstdAmt",reqForeignCurrSingle.singleDetail.payAmount,"Ccy",currency);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("ChqInstr");
//        xmlWriter.writeStartElement("DlvryMtd");
//        xmlWriter.writeElementStringNotNull("Cd",reqForeignCurrSingle.singleDetail.recCheque.equals("1")?"MLCD":"MLDB");
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("DlvrTo");
//        xmlWriter.writeElementStringNotNull("Nm", reqForeignCurrSingle.singleDetail.recCheque.equals("1")?reqForeignCurrSingle.singleDetail.recName:reqForeignCurrSingle.singleDetail.payName);
//        xmlWriter.writeStartElement("Adr");
//        xmlWriter.writeElementStringNotNull("AdrLine", reqForeignCurrSingle.singleDetail.chequeAddr); //支票邮寄地址 reqForeignCurrSingle.singleDetail.chequeAddr
//        xmlWriter.writeElementStringNotNull("AdrLine", reqForeignCurrSingle.singleDetail.chequeAddr);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("Cdtr");
//        xmlWriter.writeElementStringNotNull("Nm", reqForeignCurrSingle.singleDetail.recCheque.equals("1")?reqForeignCurrSingle.singleDetail.recName:reqForeignCurrSingle.singleDetail.payName);
//        xmlWriter.writeStartElement("PstlAdr");
//        xmlWriter.writeElementStringNotNull("AdrLine", reqForeignCurrSingle.singleDetail.chequeAddr);
//        xmlWriter.writeElementStringNotNull("AdrLine", reqForeignCurrSingle.singleDetail.chequeAddr);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//
//
//        xmlWriter.writeEndDocument();
//        xmlWriter.writeStartDocByDeclaration("\r\n"+"</Document>");
//    }
//
//    private void writeFileContentForSG(XmlTextWriter xmlWriter, ReqForeignCurrSingle reqForeignCurrSingle) throws Exception{
//        String currency = convertCurToBank(reqForeignCurrSingle.singleDetail.payCur);
//        String recCountryCode = reqForeignCurrSingle.singleDetail.recSWIFTCODE.substring(4,6);
//        String isFast = reqForeignCurrSingle.singleDetail.paySpd;
//
//        String nm = reqForeignCurrSingle.singleDetail.payName;
//        if(isFast.equals("0") && recCountryCode.equals("SG")) {
//            if (currency != null && (currency.equals("SGD"))) {
//                //取映射账户名
//                nm = getBankConfig().getMapValueByKey("actNameMapping", reqForeignCurrSingle.singleDetail.payAct);
//                if(nm.length()==0){
//                    nm = reqForeignCurrSingle.singleDetail.payName;
//                }
//            }
//        }
//        xmlWriter.writeStartElement("GrpHdr");
//        xmlWriter.writeElementStringNotNull("MsgId", reqForeignCurrSingle.singleDetail.askNumber);
//
//        String date = reqForeignCurrSingle.singleDetail.payDate + "T" + reqForeignCurrSingle.singleDetail.payTime;
//        xmlWriter.writeElementStringNotNull("CreDtTm", date);
//        xmlWriter.writeElementStringNotNull("NbOfTxs", "1");
//        xmlWriter.writeStartElement("InitgPty");
//        xmlWriter.writeElementStringNotNull("Nm", nm);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("PmtInf");
//        //流水号
//        xmlWriter.writeElementStringNotNull("PmtInfId", reqForeignCurrSingle.singleDetail.askNumber);
//        xmlWriter.writeElementStringNotNull("PmtMtd", "TRF");
//        xmlWriter.writeStartElement("PmtTpInf");
//        xmlWriter.writeStartElement("SvcLvl");
//        if(reqForeignCurrSingle.singleDetail.recSWIFTCODE.startsWith("USABA")){
//            recCountryCode = "US";
//        }
//        if(isFast!=null && isFast.equals("1")){
//                xmlWriter.writeElementStringNotNull("Cd", "URNS");//URNS
//        }else {
//            //是否跨境
//            if(recCountryCode.equals("SG")){
//                if(currency!=null && currency.equals("SGD")){
//                    xmlWriter.writeElementStringNotNull("Cd", "NURG");
//                }else{
//                    xmlWriter.writeElementStringNotNull("Cd", "URGP");
//                }
//       //         xmlWriter.writeElementStringNotNull("Cd", "NURG");
//            }else {
//                xmlWriter.writeElementStringNotNull("Cd", "URGP");
//            }
//        }
//        /*
//        if(isFast!=null && isFast.equals("1")){
//           xmlWriter.writeElementStringNotNull("Cd", "URNS");//URNS
//        }else {
//            if(currency!=null && currency.equals("SGD")){
//                xmlWriter.writeElementStringNotNull("Cd", "NURG");
//            }else{
//                xmlWriter.writeElementStringNotNull("Cd", "URGP");
//            }
//        }*/
//        xmlWriter.writeEndElement();
//
//
//        if(isFast!=null && isFast.equals("1")){
//            xmlWriter.writeStartElement("LclInstrm");
//            xmlWriter.writeElementStringNotNull("Prtry", "SGIP");
//            xmlWriter.writeEndElement();
//        }
//        xmlWriter.writeEndElement();
//        xmlWriter.writeElementStringNotNull("ReqdExctnDt", reqForeignCurrSingle.singleDetail.payDate);
//        xmlWriter.writeStartElement("Dbtr");
//        xmlWriter.writeElementStringNotNull("Nm", nm);
//        if(isFast==null || isFast.equals("0")) {
//            xmlWriter.writeStartElement("PstlAdr");
//            xmlWriter.writeElementStringNotNull("AdrLine", "TEST ORDERING PARTY ADDRESS 1");
//            xmlWriter.writeEndElement();
//        }
//
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("DbtrAcct");
//        xmlWriter.writeStartElement("Id");
//        xmlWriter.writeStartElement("Othr");
//        xmlWriter.writeElementStringNotNull("Id", reqForeignCurrSingle.singleDetail.payAct);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("DbtrAgt");
//        xmlWriter.writeStartElement("FinInstnId");
//        xmlWriter.writeElementStringNotNull("BIC", reqForeignCurrSingle.singleDetail.paySWIFTCODE);
//        xmlWriter.writeStartElement("PstlAdr");
//        String paycountryCode = reqForeignCurrSingle.singleDetail.paySWIFTCODE.substring(4,6);
//        xmlWriter.writeElementStringNotNull("Ctry", paycountryCode);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("CdtTrfTxInf");
//        xmlWriter.writeStartElement("PmtId");
//        xmlWriter.writeElementStringNotNull("EndToEndId", reqForeignCurrSingle.singleDetail.askNumber);
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("Amt");
//        xmlWriter.writeElementAttribute("InstdAmt",reqForeignCurrSingle.singleDetail.payAmount,"Ccy",currency);
//        xmlWriter.writeEndElement();
//        if(isFast!=null && isFast.equals("1")) {
//        }else{
//            xmlWriter.writeElementStringNotNull("ChrgBr", "DEBT");
//        }
//        xmlWriter.writeStartElement("CdtrAgt");
//        xmlWriter.writeStartElement("FinInstnId");
//
//        if(isFast!=null && isFast.equals("1")) {
//            xmlWriter.writeElementStringNotNull("BIC", reqForeignCurrSingle.singleDetail.recSWIFTCODE+"XXX");
//        }else {
//            xmlWriter.writeElementStringNotNull("BIC", reqForeignCurrSingle.singleDetail.recSWIFTCODE);
//        }
//        xmlWriter.writeElementStringNotNull("Nm", reqForeignCurrSingle.singleDetail.recBankName);
//
//        xmlWriter.writeStartElement("PstlAdr");
//        xmlWriter.writeElementStringNotNull("Ctry", "SG");
//       // xmlWriter.writeElementStringNotNull("AdrLine", "BENEFICIARY BANK ADDRESS LINE 1");
//
//        xmlWriter.writeEndElement();
//
////        xmlWriter.writeStartElement("PstlAdr");
//        //不存在可删除
////        xmlWriter.writeElementStringNotNull("AdrTp", "ADDR");
////        xmlWriter.writeElementStringNotNull("AdrLine", "TEST");
////        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("Cdtr");
//        xmlWriter.writeElementStringNotNull("Nm", reqForeignCurrSingle.singleDetail.recName);
//        xmlWriter.writeStartElement("PstlAdr");
//
//        xmlWriter.writeElementString("Ctry",recCountryCode);
//        xmlWriter.writeElementString("AdrLine","123 BUILDING, LEVEL 45 ABC STREET, ");
//        xmlWriter.writeElementString("AdrLine","NEW TOWN 67-8, 90123");
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeStartElement("CdtrAcct");
//        xmlWriter.writeStartElement("Id");
//        xmlWriter.writeStartElement("Othr");
//        xmlWriter.writeElementStringNotNull("Id", reqForeignCurrSingle.singleDetail.recAct);
////        xmlWriter.writeStartElement("Purp");
////        xmlWriter.writeElementString("Prtry","20");
////        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndElement();
//
//        if(isFast!=null && isFast.equals("1")) {
//            xmlWriter.writeStartElement("Purp");
//            xmlWriter.writeElementStringNotNull("Prtry", "OTHR");
//            xmlWriter.writeEndElement();
//        }
//        //交易附言
//        String purpose  = reqForeignCurrSingle.singleDetail.purpose;
//        if(purpose.length() > 35){
//            purpose = purpose.substring(0,35);
//        }
//        if(isFast!=null && isFast.equals("1")) {
//            //银行回复不需要
//            xmlWriter.writeStartElement("RmtInf");
//
//            xmlWriter.writeElementStringNotNull("Ustrd", "/IDTP/BBAN");
//            xmlWriter.writeEndElement();
//        }
////        xmlWriter.writeStartElement("Strd");
////        xmlWriter.writeStartElement("RfrdDocInf");
////        xmlWriter.writeElementString("Nb",reqForeignCurrSingle.singleDetail.askNumber);
////        xmlWriter.writeElementString("RltdDt",reqForeignCurrSingle.singleDetail.payDate);
////        xmlWriter.writeEndElement();
////        xmlWriter.writeStartElement("RfrdDocAmt");
////        xmlWriter.writeElementAttribute("InstdAmt",reqForeignCurrSingle.singleDetail.payAmount,"Ccy",currency);
////        xmlWriter.writeEndElement();
//        xmlWriter.writeEndDocument();
//        xmlWriter.writeStartDocByDeclaration("\r\n"+"</Document>");
//    }
//}
